package TowDef.generic;

import java.awt.Point;
import java.util.ArrayList;

public class Attack extends Thread {
	
	protected ArrayList<Point> path;
	protected Tower tower;
	protected ArrayList <Enemy> enemy;
	
	public Attack(ArrayList<Point> path, Tower tow, ArrayList<Enemy> enemy)
	{
		this.path = path;
		this.tower = tow;
		this.enemy = enemy;
	}
	
	public void run(){
		while(enemy.size()!=0)
		{
			boolean objetivo = false;
			int i = 0;
			while(!objetivo && i< enemy.size()){
				int j = 0;
				Point coord = new Point(enemy.get(i).getPosX(), enemy.get(i).getPosY());
				Point point = path.get(j);
				while(coord.getX()!=point.getX() && coord.getY()!=point.getY() && j<path.size()){
					j++;
					point = path.get(j);
				}
				
			try {
				this.sleep(100-tower.attackSpeed*10);
			} catch (InterruptedException e) {
				// TODO Auto-generated catch block
				e.printStackTrace();
			}
			i++;
		}
	}

}
